package com.craftplay.service;

import com.craftplay.dao.OfferMapper;

import com.craftplay.model.Offer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class OfferService {
    @Autowired
    private OfferMapper offerMapper;


    //根据某活动id列出该活动报名列表
    public List<Offer> listAllUnit(int unitId) {
        return offerMapper.selectAllUnitByUnitId(unitId);
    }

    public List<Offer> listAllOffer(int unitId) {
        return offerMapper.selectByUnitId(unitId);
    }
    public List<Offer> listAllPassedByActorId(int actorId) {
        return offerMapper.selectAllPassedByActorId(actorId);
    }

    public List<Offer> listAllReqOfferByActorId(int actorId) {return offerMapper.selectReqOfferByActorId(actorId);}
    public List<Offer> getStatistic(int id) {
        return offerMapper.getStatisticByOfferId(id);
    }
    public List<Offer> selectByActorIdAndUnitId(int id, int unitId) {
        return offerMapper.selectByActorIdAndUnitId(id, unitId);
    }

    public int updateOffer(int id, int status) {
        return offerMapper.updateStatus(id, status);
    }

    public int addOffer(Offer offer) {
        return offerMapper.insert(offer);
    }

    public Offer getOfferById(int id) {
        return offerMapper.getOfferById(id);
    }
}
